﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace ApiVersionControlDemo.Controllers.V1
{

    [ApiVersion("1.0")]
    [Route("api/demo")]
    [ApiController]
    public class DemoController : ControllerBase
    {

        // 以下两个 url 是等价的
        // http://localhost:52622/api/demo/index 
        // http://localhost:52622/api/demo/index?api-version=1.0

        [HttpGet]
        [Route("index")]
        public string Index()
        {
            return "DemoController V1 File: Index";
        }

        // http://localhost:52622/api/demo/test?api-version=2.0
        #region class 是 V1.0  在 其中有一个 V2.0 的 函数 也是 ok 的
        [ApiVersion("2.0")]
        [HttpGet]
        [Route("test")]
        public string Test()
        {
            return "DemoController V1 File: Test";
        } 
        #endregion
    }
}